﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Krile.Kernel;
using System.Net;

namespace Mixture.Data
{
    public class Account
    {
        public string Id { get; set; }

        [XmlIgnore()]
        public string PasswordRaw { get; set; }

        public string PasswordEncrypted
        {
            get
            {
                if (String.IsNullOrEmpty(PasswordRaw))
                    return null;
                else
                    return Bridge.CommonOperation.AESEncrypt(PasswordRaw);
            }
            set
            {
                if (String.IsNullOrEmpty(value))
                {
                    PasswordRaw = null;
                }
                else
                {
                    try
                    {
                        this.PasswordRaw = Bridge.CommonOperation.AESDecrypt(value);
                    }
                    catch (Exception)
                    {
                        this.PasswordRaw = null;
                    }
                }
            }
        }

        [XmlIgnore()]
        public CookieContainer CookieContainer { get; set; }
    }
}
